package com.iskny.framework.model;

import org.bee.tl.core.Context;
import org.bee.tl.core.VirtualAttributeEval;

import com.jfinal.plugin.activerecord.Model;

public class VirtualStateEval implements VirtualAttributeEval{

	@SuppressWarnings("rawtypes")
	@Override
	public Object eval(Object o, String attributeName, Context ctx) {
		if("state".equals(attributeName)){
			return ModelState.getStateInfo(((Model)o).getLong("state"));
		}
		return "error";
	}

	@SuppressWarnings("rawtypes")
	@Override
	public boolean isSuppoert(Class c, String attributeName) {

		if(Model.class.isAssignableFrom(c)&&"state".equals(attributeName)){
			return true;
		}
		return false;
	}

}
